package model.parseTree;

import model.searchers.ISearcher;
import model.searchers.URLList;

/**
 * Class WordNode is a special node of a syntax tree. It is used to represent a
 * single word to search for. The result of evaluating an object of class WordNode is the
 * result of searching for the word with a given searcher. 
 * WordNodes will always be leaves of search tree (their subtrees are null).
 * 
 * @author Anne Jul, Mark Gray, Peter Berg, Martin Poulsen
 * @version 2011.05.17
 * 
 */
public class WordNode extends SearchNode {

	/**
	 * Constructor of WordNode. Creates a search node with the specified value and empty child nodes
	 */
	// As a word node is always leaf node, its subtrees are both equal to null
	public WordNode(String value) {
		super(null, null, value);
	}

	/**
	 * Returns the resulting list of URLs on which the word occurs
	 * 
	 * @param searcher 	a given searcher to use for the search
	 * @return list of urls on which the word occurs
	 */
	@Override
	public URLList getResult(ISearcher searcher) {
		URLList result = (URLList) searcher.get(this.getValue());
		return result;
	}

}
